#!/usr/bin/python3
import sys

try:
    t = int(input())
    if t < 1 or t > 100:
        sys.exit(0)
    for i in range(t):
        d = list(input().split())
        result = (int(d[0])) ** (int(d[1]))
        ret = len(str(result))
        print(ret)

except ValueError:
    pass
except EOFError:
    pass
except MemoryError:
    pass
